{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Get Techniques from Data Sources"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Import Library"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from attackcti import attack_client"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Initialize Client"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "lift = attack_client()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Retrieve Techniques "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "techniques = lift.get_techniques_by_datasources(\n",
    "    \"Network intrusion detection system\",\n",
    "    \"Network protocol analysis\",\n",
    "    \"Netflow/Enclave netflow\",\n",
    "    \"Packet capture\",\n",
    "    \"DNS records\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "150"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(techniques)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"type\": \"attack-pattern\",\n",
      "    \"id\": \"attack-pattern--36b2a1d7-e09e-49bf-b45e-477076c2ec01\",\n",
      "    \"created_by_ref\": \"identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5\",\n",
      "    \"created\": \"2020-03-02T20:08:03.691Z\",\n",
      "    \"modified\": \"2020-09-16T15:58:18.490Z\",\n",
      "    \"name\": \"Reflection Amplification\",\n",
      "    \"description\": \"Adversaries may attempt to cause a denial of service by reflecting a high-volume of network traffic to a target. This type of Network DoS takes advantage of a third-party server intermediary that hosts and will respond to a given spoofed source IP address. This third-party server is commonly termed a reflector. An adversary accomplishes a reflection attack by sending packets to reflectors with the spoofed address of the victim. Similar to Direct Network Floods, more than one system may be used to conduct the attack, or a botnet may be used. Likewise, one or more reflector may be used to focus traffic on the target.(Citation: Cloudflare ReflectionDoS May 2017)\\n\\nReflection attacks often take advantage of protocols with larger responses than requests in order to amplify their traffic, commonly known as a Reflection Amplification attack. Adversaries may be able to generate an increase in volume of attack traffic that is several orders of magnitude greater than the requests sent to the amplifiers. The extent of this increase will depending upon many variables, such as the protocol in question, the technique used, and the amplifying servers that actually produce the amplification in attack volume. Two prominent protocols that have enabled Reflection Amplification Floods are DNS(Citation: Cloudflare DNSamplficationDoS) and NTP(Citation: Cloudflare NTPamplifciationDoS), though the use of several others in the wild have been documented.(Citation: Arbor AnnualDoSreport Jan 2018)  In particular, the memcache protocol showed itself to be a powerful protocol, with amplification sizes up to 51,200 times the requesting packet.(Citation: Cloudflare Memcrashed Feb 2018)\",\n",
      "    \"kill_chain_phases\": [\n",
      "        {\n",
      "            \"kill_chain_name\": \"mitre-attack\",\n",
      "            \"phase_name\": \"impact\"\n",
      "        }\n",
      "    ],\n",
      "    \"external_references\": [\n",
      "        {\n",
      "            \"source_name\": \"mitre-attack\",\n",
      "            \"url\": \"https://attack.mitre.org/techniques/T1498/002\",\n",
      "            \"external_id\": \"T1498.002\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"capec\",\n",
      "            \"url\": \"https://capec.mitre.org/data/definitions/490.html\",\n",
      "            \"external_id\": \"CAPEC-490\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Cloudflare ReflectionDoS May 2017\",\n",
      "            \"description\": \"Marek Majkowsk, Cloudflare. (2017, May 24). Reflections on reflection (attacks). Retrieved April 23, 2019.\",\n",
      "            \"url\": \"https://blog.cloudflare.com/reflections-on-reflections/\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Cloudflare DNSamplficationDoS\",\n",
      "            \"description\": \"Cloudflare. (n.d.). What is a DNS amplification attack?. Retrieved April 23, 2019.\",\n",
      "            \"url\": \"https://www.cloudflare.com/learning/ddos/dns-amplification-ddos-attack/\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Cloudflare NTPamplifciationDoS\",\n",
      "            \"description\": \"Cloudflare. (n.d.). What is a NTP amplificaiton attack?. Retrieved April 23, 2019.\",\n",
      "            \"url\": \"https://www.cloudflare.com/learning/ddos/ntp-amplification-ddos-attack/\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Arbor AnnualDoSreport Jan 2018\",\n",
      "            \"description\": \"Philippe Alcoy, Steinthor Bjarnason, Paul Bowen, C.F. Chui, Kirill Kasavchnko, and Gary Sockrider of Netscout Arbor. (2018, January). Insight into the Global Threat Landscape - Netscout Arbor's 13th Annual Worldwide Infrastructure Security Report. Retrieved April 22, 2019.\",\n",
      "            \"url\": \"https://pages.arbornetworks.com/rs/082-KNA-087/images/13th_Worldwide_Infrastructure_Security_Report.pdf\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Cloudflare Memcrashed Feb 2018\",\n",
      "            \"description\": \"Marek Majkowski of Cloudflare. (2018, February 27). Memcrashed - Major amplification attacks from UDP port 11211. Retrieved April 18, 2019.\",\n",
      "            \"url\": \"https://blog.cloudflare.com/memcrashed-major-amplification-attacks-from-port-11211/\"\n",
      "        },\n",
      "        {\n",
      "            \"source_name\": \"Cisco DoSdetectNetflow\",\n",
      "            \"description\": \"Cisco. (n.d.). Detecting and Analyzing Network Threats With NetFlow. Retrieved April 25, 2019.\",\n",
      "            \"url\": \"https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/netflow/configuration/15-mt/nf-15-mt-book/nf-detct-analy-thrts.pdf\"\n",
      "        }\n",
      "    ],\n",
      "    \"object_marking_refs\": [\n",
      "        \"marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168\"\n",
      "    ],\n",
      "    \"x_mitre_data_sources\": [\n",
      "        \"Sensor health and status\",\n",
      "        \"Network protocol analysis\",\n",
      "        \"Netflow/Enclave netflow\",\n",
      "        \"Network intrusion detection system\",\n",
      "        \"Network device logs\"\n",
      "    ],\n",
      "    \"x_mitre_detection\": \"Detection of reflection amplification can sometimes be achieved before the traffic volume is sufficient to cause impact to the availability of the service, but such response time typically requires very aggressive monitoring and responsiveness or services provided by an upstream network service provider. Typical network throughput monitoring tools such as netflow(Citation: Cisco DoSdetectNetflow), SNMP, and custom scripts can be used to detect sudden increases in network or service utilization. Real-time, automated, and qualitative study of the network traffic can identify a sudden surge in one type of protocol can be used to detect a reflection amplification DoS event as it starts. Often, the lead time may be small and the indicator of an event availability of the network or service drops. The analysis tools mentioned can then be used to determine the type of DoS causing the outage and help with remediation.\",\n",
      "    \"x_mitre_impact_type\": [\n",
      "        \"Availability\"\n",
      "    ],\n",
      "    \"x_mitre_is_subtechnique\": true,\n",
      "    \"x_mitre_platforms\": [\n",
      "        \"macOS\",\n",
      "        \"Windows\",\n",
      "        \"Linux\",\n",
      "        \"AWS\",\n",
      "        \"Office 365\",\n",
      "        \"Azure AD\",\n",
      "        \"GCP\",\n",
      "        \"Azure\",\n",
      "        \"SaaS\"\n",
      "    ],\n",
      "    \"x_mitre_version\": \"1.1\"\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "print(techniques[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
